package com.javaai.project.tool;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;
import org.springframework.stereotype.Component;

// 希望：大模型在执行计算时候调用我们自定义的数学公式方法
@Component
public class CaculatorTools {
    @Tool(name = "加法计算", value = "返回两个数之和")
    public int sum(
            @ToolMemoryId int memoryId,  // 指定哪个用户去调用
            @P(value = "加数1",required = true) int a,
            @P(value = "加数2",required = true) int b) {
        System.out.println("sum: " + a + " + " + b);
        return a + b;
    }
    @Tool(name = "平方根计算", value = "返回指定参数的平方根")
    public double sqrt(@ToolMemoryId int memoryId, @P(value = "计算平方根的参数",required = true) double a) {
        System.out.println("sqrt: " + a);
        return Math.sqrt(a);
    }
}
